
//Variable of Keypad
const uint8_t NORMALMODE = 0;
const uint8_t TEXTMODE = 1;
const uint8_t NUMBERMODE = 2;
const char OK = 'D';
const char CANCEL = 'C';
const char UP = 'A';
const char DOWN = 'B';
const char DELETE = '*';
const long timeDistance = 700;
const uint8_t ROWS = 4; // Four rows
const uint8_t  COLS = 4; // Four columns
const uint8_t keyNum = 4;

// Define the Keymap
char keys[ROWS][COLS] = {
{'1','2','3','A'},
{'4','5','6','B'},
{'7','8','9','C'},
{'*','0','#','D'}
};
char keyChars[keyNum*16] = {    
    '?', '/', ':', '0', //0
    '.', ',', ';', '1', //1
    'a', 'b', 'c', '2', //2
    'd', 'e', 'f', '3', //3
    'g', 'h', 'i', '4', //4
    'j', 'k', 'l', '5', //5
    'm', 'n', 'o', '6', //6
    'p', 'r', 's', '7', //7
    't', 'u', 'v', '8', //8
    'w', 'x', 'y', '9', //9
    'A', 'A', ' A', 'A', //A
    'B', 'B', 'B', 'B', //B
    'C', 'C', 'C', 'C', //C
    'D', 'D', 'D', 'D', //D
    '*', '*', '*', '*', //*
	'#', '#', '#', '#', //#
};

byte rowPins[ROWS] = {31, 35, 37, 23}; //connect to the row pinouts of the keypad
byte colPins[COLS] = {25, 27, 29, 33}; //connect to the column pinouts of the keypad
Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );
char keyPreviuos, keySelect;
uint8_t keyState;
unsigned long timeStartPress, timePreviuos;
uint8_t columnKey = 0, keyMode;
//Variable of LCD
const uint8_t fontHeight = 7;
const uint8_t fontWidth = 5;
const uint8_t distance = 1;
const uint8_t heightMenu = fontHeight + 2*distance + 1;
const uint8_t width = 127;
const uint8_t height = 63;
const uint8_t widthColumn1 = (fontWidth + 1) * 5 + 2*distance + 2;
const uint8_t widthColumn2 = (width - widthColumn1)/2;
uint8_t rowStart = 1;
uint16_t timeMinute = 100, timeSecond = 0;
//Variable of Menu
const uint8_t OKTYPE = 0;
const uint8_t OKCANCELTYPE = 1;
const uint8_t mnMain = 0;
const uint8_t mnManagementExamQuestion = 1;
const uint8_t mnExam = 2 ;
const uint8_t mnSetupSystem = 3;
const uint8_t mnCreateExamQuestion = 1;
const uint8_t mnFixExamQuestion = 2;
const uint8_t mnDelExamQuestion = 3;
const uint8_t mnLoadingTurnOld = 4;
const uint8_t mnCreateExamTurn = 1;
const uint8_t mnLoadingExamTurn = 2;
const uint8_t mnQueryExam = 3;
const uint8_t mnSetupTime = 1;
const uint8_t mnCheckClient = 2;
const uint8_t mnRegisterClient = 3;
const uint8_t mnDestroyClient = 4;
const uint8_t mnAccessSystem = 5;
const uint8_t LABELMODE = 1;
const uint8_t INPUTMODE = 2;
const uint8_t PASSMODE = 3;
bool exitFunction;
uint8_t numFunction, numInputText, indexRowInput;
uint8_t currentFunction, currentMenu;
uint8_t xCursor, yCursor, indexCursor;
char functionName[5][20];
String titleMenu;
struct InputText
{
	String content;
	String label;
	uint8_t textMode;
	uint8_t keyMode;
};
struct InputText inputText[5];